package jnpf.service.impl;

import jnpf.entity.Whu_typemessageEntity;
import jnpf.mapper.Whu_typemessageMapper;
import jnpf.service.Whu_typemessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.util.RandomUtil;


import jnpf.model.whu_typemessage.Whu_typemessagePagination;
import java.util.stream.Collectors;





import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.text.SimpleDateFormat;
import jnpf.util.*;
import java.util.*;

/**
 *
 * whu_typemessage
 * 版本： V3.2.0
 * 版权： 引迈信息技术有限公司（https://www.jnpfsoft.com）
 * 作者： JNPF开发平台组
 * 日期： 2025-06-10
 */
@Service

public class Whu_typemessageServiceImpl extends ServiceImpl<Whu_typemessageMapper, Whu_typemessageEntity> implements Whu_typemessageService {

    @Autowired
    private UserProvider userProvider;






    @Override
    public List<Whu_typemessageEntity> getList(Whu_typemessagePagination whu_typemessagePagination){
        String userId=userProvider.get().getUserId();
        List<String> AllIdList =new ArrayList();
        int total=0;
                    QueryWrapper<Whu_typemessageEntity> whu_typemessageQueryWrapper=new QueryWrapper<>();
            int whu_typemessageNum =0;
			if(StringUtil.isNotEmpty(whu_typemessagePagination.getName())){
            whu_typemessageNum++;
            whu_typemessageQueryWrapper.lambda().like(Whu_typemessageEntity::getName,whu_typemessagePagination.getName());
                    }

        if(AllIdList.size()>0){
            whu_typemessageQueryWrapper.lambda().in(Whu_typemessageEntity::getId, AllIdList);
        }
        //排序
        if(StringUtil.isEmpty(whu_typemessagePagination.getSidx())){
        whu_typemessageQueryWrapper.lambda().orderByDesc(Whu_typemessageEntity::getId);
        }else{
        whu_typemessageQueryWrapper="asc".equals(whu_typemessagePagination.getSort().toLowerCase())?whu_typemessageQueryWrapper.orderByAsc(whu_typemessagePagination.getSidx()):whu_typemessageQueryWrapper.orderByDesc(whu_typemessagePagination.getSidx());
        }
        if((total>0 && AllIdList.size()>0) || total==0){
        Page<Whu_typemessageEntity> page=new Page<>(whu_typemessagePagination.getCurrentPage(), whu_typemessagePagination.getPageSize());
        IPage<Whu_typemessageEntity> userIPage=this.page(page, whu_typemessageQueryWrapper);
        return whu_typemessagePagination.setData(userIPage.getRecords(),userIPage.getTotal());
        }else{
            List<Whu_typemessageEntity> list = new ArrayList();
            return whu_typemessagePagination.setData(list, list.size());
        }
    }
    @Override
    public List<Whu_typemessageEntity> getTypeList(Whu_typemessagePagination whu_typemessagePagination,String dataType){
        String userId=userProvider.get().getUserId();
        List<String> AllIdList =new ArrayList();
		int total=0;
                    QueryWrapper<Whu_typemessageEntity> whu_typemessageQueryWrapper=new QueryWrapper<>();
            int whu_typemessageNum =0;
			if(StringUtil.isNotEmpty(whu_typemessagePagination.getName())){
            whu_typemessageNum++;
            whu_typemessageQueryWrapper.lambda().like(Whu_typemessageEntity::getName,whu_typemessagePagination.getName());
                    }

		if(AllIdList.size()>0){
        whu_typemessageQueryWrapper.lambda().in(Whu_typemessageEntity::getId, AllIdList);
				}
        //排序
        if(StringUtil.isEmpty(whu_typemessagePagination.getSidx())){
        whu_typemessageQueryWrapper.lambda().orderByDesc(Whu_typemessageEntity::getId);
        }else{
        whu_typemessageQueryWrapper="asc".equals(whu_typemessagePagination.getSort().toLowerCase())?whu_typemessageQueryWrapper.orderByAsc(whu_typemessagePagination.getSidx()):whu_typemessageQueryWrapper.orderByDesc(whu_typemessagePagination.getSidx());
        }
        if("0".equals(dataType)){
            if((total>0 && AllIdList.size()>0) || total==0){
                Page<Whu_typemessageEntity> page=new Page<>(whu_typemessagePagination.getCurrentPage(), whu_typemessagePagination.getPageSize());
                IPage<Whu_typemessageEntity> userIPage=this.page(page, whu_typemessageQueryWrapper);
                return whu_typemessagePagination.setData(userIPage.getRecords(),userIPage.getTotal());
            }else{
                List<Whu_typemessageEntity> list = new ArrayList();
                return whu_typemessagePagination.setData(list, list.size());
            }
        }else{
            return this.list(whu_typemessageQueryWrapper);
        }
    }

    @Override
    public Whu_typemessageEntity getInfo(String id){
        QueryWrapper<Whu_typemessageEntity> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(Whu_typemessageEntity::getId,id);
        return this.getOne(queryWrapper);
    }

    @Override
    public void create(Whu_typemessageEntity entity){
        this.save(entity);
    }

    @Override
    public boolean update(String id, Whu_typemessageEntity entity){
        entity.setId(id);
        return this.updateById(entity);
    }
    @Override
    public void delete(Whu_typemessageEntity entity){
        if(entity!=null){
            this.removeById(entity.getId());
        }
    }
    //子表方法

    //列表子表数据方法

}